Apply fix from Dov Grobgeld, #61858
authorHavoc Pennington <hp@redhat.com>
Tue, 23 Oct 2001 17:45:33 +0000 (17:45 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Tue, 23 Oct 2001 17:45:33 +0000 (17:45 +0000)
2001-10-23  Havoc Pennington  <hp@redhat.com>

* gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply
fix from Dov Grobgeld, #61858

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktextlayout.c

index ef6451c0b79a7c535553eb0f11ab5424a21717e9..1f4b15680955612751c01ba5a813a210dcfc40e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply
+       fix from Dov Grobgeld, #61858
+
 2001-10-23  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextview.c (gtk_text_view_update_im_spot_location): 
index ef6451c0b79a7c535553eb0f11ab5424a21717e9..1f4b15680955612751c01ba5a813a210dcfc40e5 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply
+       fix from Dov Grobgeld, #61858
+
 2001-10-23  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextview.c (gtk_text_view_update_im_spot_location): 
index ef6451c0b79a7c535553eb0f11ab5424a21717e9..1f4b15680955612751c01ba5a813a210dcfc40e5 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply
+       fix from Dov Grobgeld, #61858
+
 2001-10-23  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextview.c (gtk_text_view_update_im_spot_location): 
index ef6451c0b79a7c535553eb0f11ab5424a21717e9..1f4b15680955612751c01ba5a813a210dcfc40e5 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply
+       fix from Dov Grobgeld, #61858
+
 2001-10-23  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextview.c (gtk_text_view_update_im_spot_location): 
index ef6451c0b79a7c535553eb0f11ab5424a21717e9..1f4b15680955612751c01ba5a813a210dcfc40e5 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply
+       fix from Dov Grobgeld, #61858
+
 2001-10-23  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextview.c (gtk_text_view_update_im_spot_location): 
index ef6451c0b79a7c535553eb0f11ab5424a21717e9..1f4b15680955612751c01ba5a813a210dcfc40e5 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply
+       fix from Dov Grobgeld, #61858
+
 2001-10-23  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextview.c (gtk_text_view_update_im_spot_location): 
index ef6451c0b79a7c535553eb0f11ab5424a21717e9..1f4b15680955612751c01ba5a813a210dcfc40e5 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply
+       fix from Dov Grobgeld, #61858
+
 2001-10-23  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextview.c (gtk_text_view_update_im_spot_location): 
index 599c82f30219253f520acfc3782d0dbe38638d5e..018a33aea8d2a7edf157793b51bc59abf749f02b 100644 (file)
@@ -2117,14 +2117,6 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
   g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
   g_return_if_fail (target_iter != NULL);
 
-  /* Adjust pixels to be on-screen. This gives nice
-     behavior if the user is dragging with a pointer grab.
-  */
-  if (x < 0)
-    x = 0;
-  if (x > layout->width)
-    x = layout->width;
-
   get_line_at_y (layout, y, &line, &line_top);
 
   display = gtk_text_layout_get_line_display (layout, line, FALSE);
@@ -2132,17 +2124,23 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
   x -= display->x_offset;
   y -= line_top + display->top_margin;
 
-  /* We clamp y to the area of the actual layout so that the layouts
-   * hit testing works OK on the space above and below the layout
+  /* If we are below the layout, position the cursor at the last character
+   * of the line.
    */
-  y = CLAMP (y, 0, display->height - display->top_margin - display->bottom_margin - 1);
-
-  if (!pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE,
-                                 &byte_index, &trailing))
+  if (y > display->height - display->top_margin - display->bottom_margin)
     {
       byte_index = _gtk_text_line_byte_count (line);
       trailing = 0;
     }
+  else
+    {
+       /* Ignore the "outside" return value from pango. Pango is doing
+        * the right thing even if we are outside the layout in the
+        * x-direction.
+        */
+      pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE,
+                                &byte_index, &trailing);
+    }
 
   line_display_index_to_iter (layout, display, target_iter, byte_index, trailing);